<?php

/**
 * Module.php
 * Classe Module : Point d'entrée du Module
 *
 * @package RHX
 * @author Donat Kamary
 */

namespace RHX;

use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;

class Module {

    /**
     * Configuration de l'AutoLoader de Zend
     *
     * @return array
     */
    public function getAutoloaderConfig() {
	return array(
	    'Zend\Loader\ClassMapAutoloader' => array(
		__DIR__ . '/autoload_classmap.php',
	    ),
	    'Zend\Loader\StandardAutoloader' => array(
		'namespaces' => array(
		    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
		),
	    ),
	);
    }

    /**
     * Fichier de Configuration du Module
     *
     * @return File
     */
    public function getConfig() {
	return include __DIR__ . '/config/module.config.php';
    }

    /**
     * Démarrage du Module
     * Chargement du Nom du Controller
     * Chargement du Nom de l'Action
     * Chargement du Nom du Module
     *
     * @param \Zend\Mvc\MvcEvent $e
     */
    public function onBootstrap(MvcEvent $e) {
	$eventManager		 = $e->getApplication()->getEventManager();
	$moduleRouteListener	 = new ModuleRouteListener();
	$moduleRouteListener->attach($eventManager);

	$sharedEvents = $eventManager->getSharedManager();
	$sharedEvents->attach(__NAMESPACE__, 'dispatch', function($e) {
		    $controller	 = $e->getTarget();
		    $route		 = $controller->getEvent()->getRouteMatch();
		    $e->getViewModel()->setVariables(
			    array('controllerName' => $route->getParam('__CONTROLLER__', 'index'),
				'actionName'	 => $route->getParam('action', 'index'),
				'moduleName'	 => strtolower(__NAMESPACE__))
		    );
		}, 100);
    }

    /**
     * Configuration des Services
     *
     * @return array
     */
    public function getServiceConfig() {
	return array(
	    'factories'			 => array(
		'RHX\Model\Table\PeriodeTable' => function($sm) {
		    return new Model\Table\PeriodeTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\SiteTable'	 => function($sm) {
		    return new Model\Table\SiteTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\CodeActiviteTable' => function($sm) {
		    return new Model\Table\CodeActiviteTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\SemaineTable' => function($sm) {
		    return new Model\Table\SemaineTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\PeriodeSemaineTable' => function($sm) {
		    return new Model\Table\PeriodeSemaineTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\ProfilTable' => function($sm) {
		    return new Model\Table\ProfilTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\TransportTable' => function($sm) {
		    return new Model\Table\TransportTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\EmployeTable' => function($sm) {
		    return new Model\Table\EmployeTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\PosteTable' => function($sm) {
		    return new Model\Table\PosteTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\AvenantTable' => function($sm) {
		    return new Model\Table\AvenantTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\AvenantHistoryTable' => function($sm) {
		    return new Model\Table\AvenantHistoryTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\EmployeDisponibiliteTable' => function($sm) {
		    return new Model\Table\EmployeDisponibiliteTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\EmployeTemplateTable' => function($sm) {
		    return new Model\Table\EmployeTemplateTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\PlanningTemplateTable' => function($sm) {
		    return new Model\Table\PlanningTemplateTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\PlanningPeriodeTable' => function($sm) {
		    return new Model\Table\PlanningPeriodeTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\PlanningSemaineTable' => function($sm) {
		    return new Model\Table\PlanningSemaineTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\View\PSPlanningView' => function($sm) {
		    return new Model\View\PSPlanningView($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\TransfertTable' => function($sm) {
		    return new Model\Table\TransfertTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Object\XRules' => function($sm) {
		    return new Model\Object\XRules($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\ContratTypeTable' => function($sm) {
		    return new Model\Table\ContratTypeTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\MotifTable' => function($sm) {
		    return new Model\Table\MotifTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\DiplomeTable' => function($sm) {
		    return new Model\Table\DiplomeTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\FormationTable' => function($sm) {
		    return new Model\Table\FormationTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\EmployeDiplomeTable' => function($sm) {
		    return new Model\Table\EmployeDiplomeTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
		'RHX\Model\Table\EmployeFormationTable' => function($sm) {
		    return new Model\Table\EmployeFormationTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
                'RHX\Model\Table\SiteHoraireTable' => function($sm) {
		    return new Model\Table\SiteHoraireTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
                'RHX\Model\Table\PrimeTable' => function($sm) {
		    return new Model\Table\PrimeTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
                'RHX\Model\Table\TauxProcessTable' => function($sm) {
		    return new Model\Table\TauxProcessTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
                'RHX\Model\Table\TiersTable' => function($sm) {
		    return new Model\Table\TiersTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
                'RHX\Model\Table\SiteDocTable' => function($sm) {
		    return new Model\Table\SiteDocTable($sm->get('Zend\Db\Adapter\Adapter2'));
		},
	    ),
	);
    }

}

?>
